/*
 * @Author: yangni 920556271@qq.com
 * @Date: 2023-12-10 12:14:27
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-03-27 11:28:35
 * @FilePath: /yt-devops/lib/pages/devices/device_tab/basic_info/sub_debvice_tree/sub_debvice_tree_view.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:yt_devops/components/app_bar/app_bar_widget.dart';
import 'package:yt_devops/components/brn/brn_bottom_button_panel.dart';
import 'package:yt_devops/components/log_utils.dart';
import 'package:yt_devops/components/yt_expandable_tree/model/tree_mode.dart';
import 'package:yt_devops/components/yt_expandable_tree/yt_expandable_tree.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/styles/styles.dart';
import 'sub_debvice_tree_controller.dart';

class SubDebviceTreePage extends GetView<SubDebviceTreeController> {
  SubDebviceTreePage({Key? key}) : super(key: key);

  List<TreeNode> treeData = [];

  @override
  Widget build(BuildContext context) {
    Log.d('选择设备===');
    return Scaffold(
      appBar: AppBarWidget.defaultAppBar(ResKey.selectDevice.tr),
      body: GetBuilder<SubDebviceTreeController>(
        builder: (controller) => SafeArea(
            child: Column(
          children: [
            Expanded(
              child: Container(
                color: Colour.white,
                margin: EdgeInsets.only(top: 10.h),
                padding: EdgeInsets.symmetric(horizontal: 16.w),
                child: YtExpandableTree(
                  treeData: controller.treeData,
                  checkedValues: controller.initSelectedDeviceIds,
                  onValueChanged: (newVal) => controller.checkHandle(newVal),
                ),
              ),
            ),
            YtBrnBottomButtonPanel(
              mainButtonName: ResKey.save.tr,
              mainButtonOnTap: controller.save,
              secondaryButtonName: ResKey.cancel.tr,
              secondaryButtonOnTap: () => Get.back(),
              secondaryButtonBorder: Border.all(color: Colour.dividerColor),
            )
          ],
        )),
      ),
    );
  }
}
